package com.example.dao;

import com.example.pojo.Users;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository;

import java.util.List;

public interface UsersRepositoryQueryAnnotation extends Repository<Users, Integer> {

    @Query("from Users where name = ?")
    List<Users> queryByNameUseHQL(String name);

    @Query(value = "select * from t_users where name = ?", nativeQuery = true)
    List<Users> queryByNameUseSQL(String name);

    @Modifying
    @Query("update Users set name = ? where id = ?")
    void updateUsersNameById(String name,Integer id);

}
